/**
 * @desc 按钮组件
 * @props { string } type 按钮类型
 * @props { bool } loading  是否显示loading
 * @props { func } handler 点击按钮事件
 * @props { string } size 按钮大小
 */
import React from 'react'
import { Button, Switch } from 'antd';
import PropTypes from 'prop-types'
import { isContained } from '@/utils/tools'
import _connect from '@/_connect'
class TheSwitch extends React.Component {
    render() {
        let allPermi = this.props.idents
        const { children, haspermi } = this.props;
        return <Switch
            size='large'
            style={{ 'display': (haspermi && haspermi.length >= 0 && isContained(allPermi, haspermi)) ? '' : 'none', }}
            {...this.props}>
            {children}
        </Switch>

    }
}

TheSwitch.propTypes = {
    loading: PropTypes.bool,
    type: PropTypes.string,
    size: PropTypes.string,
    color: PropTypes.string,
    danger: PropTypes.bool,
    haspermi: PropTypes.array
}
TheSwitch.defaultProps = {
    loading: false,
    type: 'link',
    size: 'default',
    color: '#1890ff',
    danger: false,
    haspermi: []
}
export default _connect(TheSwitch)
